const {AMOUNT_IS_REQUIRED,INFORMATION_NULL}=require('../error/errorType')
const serviceSql=require('../service/service')

const verifyOrder=async(ctx,next)=>{
    const {stadiumId}=ctx.request.body
    if(!stadiumId){
        return ctx.app.emit('error',new Error(AMOUNT_IS_REQUIRED),ctx)
    }
    let result=await serviceSql.stadiumOne(stadiumId)
    if(!result.length){
        return ctx.app.emit('error',new Error(INFORMATION_NULL),ctx)
    }
    ctx.stadium=[result]
    ctx.stadiumId=stadiumId
    await next()
}

module.exports={
    verifyOrder
}